package day_01;

import java.io.*;

public class Homework {
    public static void main(String[] args) throws IOException {
        String path = ".\\Test\\copy.txt";
        File file = new File(".\\Test\\2.txt");
        Homework homework = new Homework();
        homework.replaceFile(file,path);
    }

    public void replaceFile(File file,String path) throws IOException {
        StringBuffer sb = new StringBuffer();
        String str = null;
        BufferedReader br = new BufferedReader(new FileReader(file));
        BufferedWriter bw = new BufferedWriter(new FileWriter(path));


        while((str=br.readLine()) != null){
            sb.append(str,0,str.length());
            sb.append("\n");
        }
        System.out.println(sb.toString());
        str = sb.toString().replaceAll("\\{name}","修狗").replaceAll("\\{type}","dog").replaceAll("\\{age}","88");
        System.out.println(str);
        bw.write(str);



        br.close();
        bw.close();

    }

}
